package cn.sc.summer.adapter.controller;

import cn.sc.summer.constant.model.Result;
import cn.sc.summer.domain.service.SysService;
import cn.sc.summer.protocol.form.QRCodeForm;
import cn.sc.summer.protocol.form.WebFileForm;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * 类名：测试用控制层
 *
 * @author a-xin
 * @date 2023/11/27 08:17
 */
@Slf4j
@RestController
@RequestMapping("/sys")
@Api(tags = "sys-测试用控制层")
public class SysController {

    @Resource
    private SysService sysService;

    @PostMapping("/createQRCode")
    @ApiOperation(value = "根据内容生成二维码")
    public void createQRCode(@Validated @RequestBody QRCodeForm form, HttpServletResponse response) {
        sysService.createQRCode(form, response);
    }

    @PostMapping("/getWebFile")
    @ApiOperation(value = "根据网络文件地址下载到本地")
    public Result<String> getWebFile(@Validated @RequestBody WebFileForm form) {
        sysService.getWebFile(form);
        return Result.success();
    }

    @ApiOperation(value = "测试API接口")
    @PostMapping(value = "/testApi")
    public Result<Object> testApi() {
        return Result.success(sysService.testApi());
    }

}
